<div class="tableform widgetconfig">
<div class="division" style='border:1px solid #d8d8d8;'>
<table width="100%" border="0" cellspacing="0" cellpadding="0">  
  <tr>
    <th><{t app='b2c'}>标题：<{/t}></th>
    <td><{input type="text" name="title" value=$setting.title|default:'请填写标题'}></td>
  </tr>
</table>
</div>
<div class="division" id="add_ad_pic" style="border:1px solid #d8d8d8;">

</div>
<div class="division">
<{input type="storegoodsfilter" value=$setting.adjunct.items.0 member_id=$data.store.account_id}>
</div>
<div class="division" style='border:1px solid #d8d8d8;'>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th><{t app='business'}>排行依据：<{/t}></th>
    <td>
            <select name="ranking"> 
    <{foreach from=$data.orderby item=orderby key=key}>
    <option value="<{$orderby.sql}>" <{if $setting.ranking==$orderby.sql}>selected<{/if}>><{$orderby.label}></option>
    <{/foreach}>
    </select></td>
  </tr>
  <tr>
    <th><{t app='b2c'}>榜单显示商品数：<{/t}></th>
    <td><{input name="limit" value=$setting.limit|default:'10' size=8 required="true" type="digits" id='show_limit'}></td>
  </tr>
</table>
</div>
</div>
<script>
  (function(){
    function getCfgForm(id){
      var config = $$(id)[0];
      while(config.tagName != 'FORM'){
        config = config.getParent();
      }
      return config;
    }
    var pic_html='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><th><{t app="b2c"}>广告尺寸高度：<{/t}></th>';
    pic_html+='<td><input type="text" vtype="digits" required="true" class="x-input" autocomplete="off" name="ad_pic_height" style="width:40px" value="<{$setting.ad_pic_height|default:212}>">px';
	pic_html+='</td></tr><tr><th><{t app="b2c"}>图片：<{/t}></th><td><input type=hidden name="ad_pic" value="<{$setting.ad_pic}>"><input name="ad_pic"  vtype="purl" required="true"  class="imgsrc x-input" id="ad_pic" value="<{$setting.ad_pic}>"><input type=button value="<{t app="b2c"}>上传图片<{/t}>" class="uploadbtn" onclick="addPic()">';
	pic_html+='</td></tr><tr><th><{t app="b2c"}>图片描述：<{/t}></th>';
    pic_html+='<td><input type="text" class="x-input" autocomplete="off"  name="ad_pic_txt" value="<{$setting.ad_pic_txt}>"></td>';
    pic_html+='</tr><tr><th><{t app="b2c"}>图片链接：<{/t}></th><td><input type="text" class="x-input" autocomplete="off"  vtype="purl"  name="ad_pic_link" value="<{$setting.ad_pic_link}>"></td>';
    pic_html+=' </tr>';
    pic_html+='</table>';
    function getWgtTpl(){
      var sels = getCfgForm('.wgtconfig').getElements('select');
      var wgtTpl = '';
      sels.each(function(sel){
        if(sel.getProperty('name') == '__wg[tpl]') wgtTpl = sel;
      });
      return wgtTpl;
    }
    var SelectTp = getWgtTpl();
    SelectTp.addEvent('change',function(){
      if(this.value == 'electron_ad.html'){
        $('add_ad_pic').set('html',pic_html).show();
      }else{
        $('add_ad_pic').empty().hide();
      }
    });
    if(SelectTp.value!='electron_ad.html'){
        $('add_ad_pic').empty().hide();
    }
   

  })();
  function addPic(){
			var url='btools-alertpages.html?dd='+Date.now()+'&goto='+encodeURIComponent("btools-image_broswer.html?type=big");
			Ex_Loader('modedialog',function(){
			return new imgDialog(url,{onCallback:function(image_id,image_src){
					 $('ad_pic').value=image_src;
			}})	;
			});
		}
</script>